<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="inventario" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{inventarioHome.managed ? 'Edit' : 'Add'} Inventario</f:facet>


            <s:decorate id="invCodigoField" template="layout/edit.xhtml">
                <ui:define name="label">Inv codigo</ui:define>
                <h:inputText id="invCodigo"
                       required="true"
                       disabled="#{inventarioHome.managed}"
                          value="#{inventarioHome.instance.invCodigo}">
                    <a:support event="onblur" reRender="invCodigoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="depCodigoField" template="layout/edit.xhtml">
                <ui:define name="label">Dep codigo</ui:define>
                <h:inputText id="depCodigo"
                          value="#{inventarioHome.instance.depCodigo}">
                    <a:support event="onblur" reRender="depCodigoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invFechaField" template="layout/edit.xhtml">
                <ui:define name="label">Inv fecha</ui:define>
                <rich:calendar id="invFecha"
                          value="#{inventarioHome.instance.invFecha}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="invIteCantidadField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite cantidad</ui:define>
                <h:inputText id="invIteCantidad"
                          value="#{inventarioHome.instance.invIteCantidad}">
                    <a:support event="onblur" reRender="invIteCantidadField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invIteCantidadAnteriorField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite cantidad anterior</ui:define>
                <h:inputText id="invIteCantidadAnterior"
                          value="#{inventarioHome.instance.invIteCantidadAnterior}">
                    <a:support event="onblur" reRender="invIteCantidadAnteriorField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invIteCostoDolaresField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite costo dolares</ui:define>
                <h:inputText id="invIteCostoDolares"
                          value="#{inventarioHome.instance.invIteCostoDolares}"
                           size="20">
                    <a:support event="onblur" reRender="invIteCostoDolaresField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invIteCostoTField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite costo t</ui:define>
                <h:inputText id="invIteCostoT"
                          value="#{inventarioHome.instance.invIteCostoT}"
                           size="20">
                    <a:support event="onblur" reRender="invIteCostoTField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invItePrecioField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite precio</ui:define>
                <h:inputText id="invItePrecio"
                          value="#{inventarioHome.instance.invItePrecio}"
                           size="20">
                    <a:support event="onblur" reRender="invItePrecioField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="invItePrecioDolaresField" template="layout/edit.xhtml">
                <ui:define name="label">Inv ite precio dolares</ui:define>
                <h:inputText id="invItePrecioDolares"
                          value="#{inventarioHome.instance.invItePrecioDolares}"
                           size="20">
                    <a:support event="onblur" reRender="invItePrecioDolaresField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <s:decorate id="subdepCodigoField" template="layout/edit.xhtml">
                <ui:define name="label">Subdep codigo</ui:define>
                <h:inputText id="subdepCodigo"
                          value="#{inventarioHome.instance.subdepCodigo}">
                    <a:support event="onblur" reRender="subdepCodigoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{inventarioHome.persist}"
                       disabled="#{!inventarioHome.wired}"
                       rendered="#{!inventarioHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{inventarioHome.update}"
                       rendered="#{inventarioHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{inventarioHome.remove}"
                      immediate="true"
                       rendered="#{inventarioHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Inventario.xhtml"
                rendered="#{inventarioHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty inventarioFrom ? 'InventarioList' : inventarioFrom}.xhtml"
                rendered="#{!inventarioHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Inv item stock">
    <div class="association" id="invItemStockParent">

        <h:outputText value="There is no invItemStock associated with this inventario."
                   rendered="#{inventarioHome.instance.invItemStock == null}"/>

        <rich:dataTable var="_invItemStock"
                   value="#{inventarioHome.instance.invItemStock}"
                rendered="#{inventarioHome.instance.invItemStock != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="invItemStockTable">
            <h:column>
                <f:facet name="header">Item secuenca</f:facet>
                <h:outputText value="#{_invItemStock.itemSecuenca}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dep codigo</f:facet>
                <h:outputText value="#{_invItemStock.depCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Inv grupo gru codigo</f:facet>
                <h:outputText value="#{_invItemStock.invGrupo.gruCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Inv unidad medida und codigo</f:facet>
                <h:outputText value="#{_invItemStock.invUnidadMedida.undCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ite codigo</f:facet>
                <h:outputText value="#{_invItemStock.iteCodigo}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ite costo</f:facet>
                <h:outputText value="#{_invItemStock.iteCosto}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Ite costo dolares</f:facet>
                <h:outputText value="#{_invItemStock.iteCostoDolares}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Ite costo t</f:facet>
                <h:outputText value="#{_invItemStock.iteCostoT}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Ite descripcion</f:facet>
                <h:outputText value="#{_invItemStock.iteDescripcion}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ite nombre</f:facet>
                <h:outputText value="#{_invItemStock.iteNombre}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ite precio</f:facet>
                <h:outputText value="#{_invItemStock.itePrecio}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Ite precio dolares</f:facet>
                <h:outputText value="#{_invItemStock.itePrecioDolares}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Ite unidad</f:facet>
                <h:outputText value="#{_invItemStock.iteUnidad}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Subdep codigo</f:facet>
                <h:outputText value="#{_invItemStock.subdepCodigo}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{inventarioHome.instance.invItemStock != null ? 'Change' : 'Select'} invItemStock"
                       view="/InvItemStockList.xhtml">
                <f:param name="from" value="InventarioEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
